<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>档案管理</title>
<!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
<script src="libs/jquery-1.12.1.min.js"></script>
<link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script src="libs/handlebars.min.js"></script>
<script src="libs/getQueryString.js"></script>
<script src="libs/jquery.backstretch.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="page-header">
				<h2>
					<strong>档案管理</strong>
				</h2>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="col-md-8">
			<ul class="nav nav-pills">
				<li><a href="index.html">首页</a></li>
				<li><a href="#">用户：<span id="nickname"></span></a></li>
				<button id="tuichu">用户退出</button>
			</ul>
		</div>
	</div>
	<div class="container">
		<!-- Nav tabs -->
		<ul class="nav nav-tabs" role="tablist">
			<li role="presentation" class="active"><a href="#home"
				aria-controls="home" role="tab" data-toggle="tab">信息</a></li>
			<li role="presentation"><a href="#profile"
				aria-controls="profile" role="tab" data-toggle="tab">图片</a></li>
			<li role="presentation"><a href="#messages"
				aria-controls="messages" role="tab" data-toggle="tab">修改图片</a></li>
		</ul>
		<!-- Tab panes -->
		<div class="tab-content">
			<div role="tabpanel" class="tab-pane active" id="home">
				<div class="panel-body" id="list1">
					<div class="container">
						<div class="row">
							<div class="col-md-3 ">
								<div class="form-group">
									<label for="archive_id">档案号</label> <input type="text"
										class="form-control" id="archive_id" />
								</div>
								<div class="form-group">
									<label for="identity">身份证</label> <input type="text"
										class="form-control" id="identity" />
								</div>
								<div class="form-group">
									<label for="name">姓名</label> <input type="text"
										class="form-control" id="name" />
								</div>
								<div class="form-group">
									<label for="gender">性别</label> <input type="text"
										class="form-control" id="gender" />
								</div>
								<div class="form-group">
									<label for="brithday">生日</label> <input type="text"
										class="form-control" id="brithday" />
								</div>
								<div class="form-group">
									<label for="date_retire1">预退休日期</label> <input type="text"
										class="form-control" id="date_retire1" />
								</div>
								<div class="form-group">
									<label for="date_retire2">实际退休日期</label> <input type="text"
										class="form-control" id="date_retire2" />
								</div>
								<div class="form-group">
									<label for="sp">特殊工种</label> <input type="text"
										class="form-control" id="sp" />
								</div>
								<div class="form-group">
									<label for="fc">女管理岗位</label> <input type="text"
										class="form-control" id="fc" />
								</div>
								<div class="form-group">
									<label for="title">职称</label> <input type="text"
										class="form-control" id="title" />
								</div>
								<div class="form-group">
									<label for="seniority">工龄</label> <input type="text"
										class="form-control" id="seniority" />
								</div>
								<div>
									<button id="update" class="btn btn-primary ">修改</button>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div role="tabpanel" class="tab-pane" id="profile">
				<div class="row" id="profile"></div>
			</div>
			<div role="tabpanel" class="tab-pane" id="messages">
				<form id="form" action="" method="post"
					enctype="multipart/form-data">
					<input type="file" name="file" />
					<button type="submit">上传</button>
				</form>
			</div>
		</div>
	</div>

	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<hr />
			</div>
		</div>
	</div>

	<script id="template" type="text/x-handlebars-template">
    {{#each item}}
    <div class="col-md-3">
		<div class="thumbnail">
			<a href="photo_del.html?id={{id}}"><img src="upload/{{archive_id}}/{{name}}" /></a>
		</div>
    </div>
    {{/each}}
    </script>

	<script type="text/javascript">
		$(function() {
			$.backstretch("image/4.jpg");
			var id = getQueryString('id');
			var url = 'query.action?id=' + id;
			$.getJSON(url, function(res) {
				$('#id').val(res[0].id);
				$('#archive_id').val(res[0].archive_id);
				$('#identity').val(res[0].identity);
				$('#name').val(res[0].name);
				$('#gender').val(res[0].gender);
				$('#brithday').val(res[0].brithday);
				$('#date_retire1').val(res[0].date_retire1);
				$('#date_retire2').val(res[0].date_retire2);
				$('#sp').val(res[0].sp);
				$('#fc').val(res[0].fc);
				$('#title').val(res[0].title);
				$('#seniority').val(res[0].seniority);
			});
		});
	</script>
	<script type="text/javascript">
		$(function() {
			var id = getQueryString('id');
			var url = 'query.action?id=' + id;

			$('#form').attr('action', id + '/upload.action');

			$.getJSON('query_file.action?id=' + id, function(res) {
				var data = {
					'item' : res
				};
				var t = Handlebars.compile($('#template').html());
				$('#profile').html(t(data));
			})
			$('#update').click(function() {
				$.post('update.action?id=' + id, {
					id : $('#id').val(),
					archive_id : $('#archive_id').val(),
					identity : $('#identity').val(),
					name : $('#name').val(),
					gender : $('#gender').val(),
					brithday : $('#brithday').val(),
					date_retire1 : $('#date_retire1').val(),
					date_retire2 : $('#date_retire2').val(),
					sp : $('#sp').val(),
					fc : $('#fc').val(),
					title : $('#title').val(),
					seniority : $('#seniority').val()
				}, function(res, status) {
					if ('OK' == res) {
						alert('修改成功');
						window.location.href = "index.html"
					} else {
						alert('错误')
					}
				});
			});
		});
	</script>
	<script type="text/javascript">
		$('#myTabs a').click(function(e) {
			e.preventDefault()
			$(this).tab('show')
		})
	</script>
</body>
</html>
